package org.yu.team2023.flashdays.client.render;


import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.VertexFormat;
import net.minecraft.Util;
import net.minecraft.client.renderer.RenderStateShard;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.ShaderInstance;
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.Nullable;

import java.util.function.Function;

public class SimpleRenderType extends RenderType {
    @Nullable
    public static ShaderInstance SHADERTEST;
    protected static final RenderStateShard.ShaderStateShard TEST_SHADER = new RenderStateShard.ShaderStateShard(()-> SHADERTEST);
    public static final Function<ResourceLocation, RenderType> IMAGE = Util.memoize((resourceLocation) -> {
        CompositeState compositeRenderType = CompositeState.builder().setShaderState(RenderStateShard.POSITION_COLOR_TEX_SHADER).setDepthTestState(RenderStateShard.LEQUAL_DEPTH_TEST).setTextureState(new TextureStateShard(resourceLocation, false, false)).setCullState(RenderStateShard.NO_CULL).setWriteMaskState(COLOR_DEPTH_WRITE).createCompositeState(true);
        return create("flashdays:world_image", DefaultVertexFormat.POSITION_COLOR_TEX, VertexFormat.Mode.QUADS, 1024, false, false, compositeRenderType);
    });
    public static final Function<ResourceLocation, RenderType> TEST = Util.memoize((resourceLocation) -> {
        CompositeState compositeRenderType = CompositeState.builder().setShaderState(TEST_SHADER).setDepthTestState(RenderStateShard.LEQUAL_DEPTH_TEST).setTextureState(new TextureStateShard(resourceLocation, false, false)).setWriteMaskState(COLOR_DEPTH_WRITE).setCullState(RenderStateShard.NO_CULL).createCompositeState(true);
        return create("flashdays:test", DefaultVertexFormat.POSITION_COLOR_TEX, VertexFormat.Mode.QUADS, 1024, false, false, compositeRenderType);
    });
    public SimpleRenderType(String pName, VertexFormat pFormat, VertexFormat.Mode pMode, int pBufferSize, boolean pAffectsCrumbling, boolean pSortOnUpload, Runnable pSetupState, Runnable pClearState) {
        super(pName, pFormat, pMode, pBufferSize, pAffectsCrumbling, pSortOnUpload, pSetupState, pClearState);
    }
}
